<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var person = {"name": "zhangsan", "age": 62, "city": "BeiJing"};
    console.log(person);
    //JSON字符串转JS对象
    var jsonStr = '{"name":"孙悟空","age":18,"gender":"男"}';
    var obj = JSON.parse(jsonStr);
    console.log(obj);
    //JS对象转JSON字符串
    var obj = {name: "猪八戒", age: 28, gender: "男"};
    var jsonStr = JSON.stringify(obj);
    console.log(jsonStr);
    

</script>
</html>